<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<title>漂亮的响应式Bootstrap后台管理系统模板MatAdmin</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/bootstrap.min.css" />
<!-- <link rel="stylesheet" href="/phpwmscm/PUBLIC/css/bootstrap-responsive.min.css" /> -->
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/fullcalendar.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/matrix-style.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/matrix-media.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/index.css" />
<link href="/phpwmscm/PUBLIC/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/jquery.gritter.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
<script src="/phpwmscm/PUBLIC/js/jquery-1.8.0.min.js"></script> 
 <style>
		td{
			white-space:nowrap;
			overflow:hidden;
			word-break:keep-all;
		}
		body {
         overflow-y:hidden;
          }
</style>
<style>

.parent {
	display: block;
	background: gray;
	height:0px;
    padding-bottom:100%
}

.parent {
	 writing-mode: horizontal-tb; 
}

.child {
	margin: 10px 10px 10px 10px;
	border: 5px solid black;
	padding: 5px;
	width: 450px;
	height: 1050px;
	text-align: center;
	background: lightblue;
	writing-mode: horizontal-tb;
	display: inline-block;
}
</style>

</head>
<body>
        
<!--Header-part-->
<div id="header">
  <h1><a href="dashboard.html">MatAdmin</a></h1>
</div>
<!--close-Header-part-->
<!--top-Header-menu-->
<div id="user-nav" class="navbar navbar-inverse">
  <ul class="nav">
    <li  class="dropdown" id="profile-messages" ><a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"><i class="icon icon-user"></i>  <span id="userbeifn" class="text"><?php echo ($user); ?></span><b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a href="#"><i class="icon-user"></i> 我的资料</a></li>
        <li class="divider"></li>
        <li><a href="#"><i class="icon-check"></i> 我的任务</a></li>
        <li class="divider"></li>
        <li><a href="<?php echo U('Login/logout');?>"><i class="icon-key"></i> 退出</a></li>
      </ul>
    </li>
    <li class="dropdown" id="menu-messages"><a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle"><i class="icon icon-envelope"></i> <span class="text">消息</span> <span class="label label-important">5</span> <b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a class="sAdd" title="" href="#"><i class="icon-plus"></i> 新消息</a></li>
        <li class="divider"></li>
        <li><a class="sInbox" title="" href="#"><i class="icon-envelope"></i> 收件箱</a></li>
        <li class="divider"></li>
        <li><a class="sOutbox" title="" href="#"><i class="icon-arrow-up"></i> 发件箱</a></li>
        <li class="divider"></li>
        <li><a class="sTrash" title="" href="#"><i class="icon-trash"></i> 发送</a></li>
      </ul>
    </li>
    <li class=""><a title="" href="#"><i class="icon icon-cog"></i> <span class="text">设置</span></a></li>
    <li class=""><a title="" href="<?php echo U('Login/logout');?>"><i class="icon icon-share-alt"></i> <span class="text">退出</span></a></li>
  </ul>
</div>
<!--close-top-Header-menu-->
<!--start-top-serch-->
<div id="search">
  <input type="text" placeholder="输入搜索内容..."/>
  <button type="submit" class="tip-bottom" title="Search"><i class="icon-search icon-white"></i></button>
</div>
<!--close-top-serch-->
<div id="sidebar"><a href="#" class="visible-phone"><i class="icon-home"></i> 控制台</a>
  <ul>
    <!-- <li><a href="<?php echo U('Index/index');?>"><i class="icon-home"></i> <span>首页</span></a> </li>
    <li> <a href="<?php echo U('Log/index');?>"><i class="icon-signal"></i> <span>库存单品编码</span></a> </li>
    <li> <a href="<?php echo U('Lsdl/index');?>"><i class="icon-signal"></i> <span>客户门店添加</span></a> </li>
    <li> <a href="<?php echo U('Ls/index');?>"><i class="icon-signal"></i> <span>门店报单编辑</span></a> </li>
    <li class="active"> <a href="<?php echo U('Lsrb/index');?>"><i class="icon-signal"></i> <span>已报订单确认</span></a> </li>
    <li> <a href="<?php echo U('Nslsrb/index');?>"><i class="icon-signal"></i> <span>日报新增删除</span></a> </li>
    <li > <a href="<?php echo U('Sc/index');?>"><i class="icon-signal"></i> <span>商超批量派车</span></a> </li>
    <li> <a href="<?php echo U('Scdl/index');?>"><i class="icon-signal"></i> <span>商超独立派车</span></a> </li>
    <li> <a href="<?php echo U('Wpcmd/index');?>"><i class="icon-signal"></i> <span>未派订单处理</span></a> </li> -->
  </ul>
</div>

<!--sidebar-menu-->

<!--main-container-part-->
<div id="content">
<!--breadcrumbs-->
  <div id="content-header">
    <div id="f"> <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a></div>
  </div>
<!-- End-breadcrumbs -->

<!-- Action boxes -->
  
                      <!--  <form action="<?php echo U('Dddy/index');?>" enctype="multipart/form-data" method="post"> -->	
                            <datalist id="typelist"> 
                            </datalist>					
							订单日期开始<input type=date id="dbb1" name=time_1 step=1 value=$_POST[time_1]> 
							订单日期结束<input type=date id="dbb2" name=time_2 step=1 value=$_POST[time_2]> 
							<input type=submit id="fbt8" class="span2" name=submit value=查询正常订单> 
							<input type=submit id="fbt17" class="span2" name=submit value=查询作废订单> 
							<input type=submit id="fbt18" class="span2" name=submit value=查询全部订单> 
							<input type=submit id="fbt9" class="span1" name=submit value=导出数据> 
													
							<div class="control-group">							
							<div class="controls">
					                            门店<input type="text"  list="listItem" placeholder="请选择门店" id="fbt10" name=project_name_1 value="全部">
					        <datalist id="listItem">
					             <option>全部</option>						     
					        </datalist>

					
									配送类型<select name=project_name_2 id="fbt11">	
									    <option>全部</option>									
										<option>市内</option>
										<option>零担</option>
										<option>自提</option>
								    </select>	
								   <!-- 只有已打印订单可以过账，如果有空单，点击下 打印 即可-->
									是否已打印<select name=project_name_3 id="fbt12">										  
									    <option>已打印</option>										   										  																									
								    </select>	
								               是否已过账(正常订单)<select name=project_name_3 id="fbt14">	
									    <option>未过账</option>	
									    <option>已过账</option>											  																									
								    </select>	
								             单品(全部订单)<input type="text"  list="listItem1" placeholder="请选择单品" id="fbt114" name=project_name_4 value="全部">
					                <datalist id="listItem1">
					                          <option>全部</option>						     
					                </datalist>								           												         
								</div>
						    </div>					    					
						<!-- </form> -->
                        <button id="fbt1">整单过账</button> 
                        <button id="fbt7">整单作废</button>
                        <p></p>	
                        <button id="fbt3">全选</button>						          
						<button id="fbt15">单品作废</button>
						<!-- 这个空间默认隐藏，只有点击 查询作废订单 才可以使用，其他隐藏 点击查询相反。 -->
						<button id="fbt16">作废订单恢复</button><button id="fbt19">作废订单删除</button>
						<button id="fbt20">新增单品行</button><button id="fbt21">删除新增的单品行</button>
<div>
<div    class="pre-scrollablezdy">                       
<div id="wwf">
                     		
</div>
</div>
</div>

<!-- End-Action boxes -->    

</div>

<!--end-main-container-part-->

<!--Footer-part-->

<div class="row-fluid">
  <div id="footer" class="span12">Copyright &copy; 2018.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a> </div>
</div>


<script src="/phpwmscm/PUBLIC/js/excanvas.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.ui.custom.js"></script> 
<script src="/phpwmscm/PUBLIC/js/bootstrap.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.flot.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.flot.resize.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.peity.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/fullcalendar.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.dashboard.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.gritter.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.interface.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.chat.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.validate.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.form_validation.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.wizard.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.uniform.js"></script> 
<script src="/phpwmscm/PUBLIC/js/select2.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.popover.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.dataTables.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.tables.js"></script> 
<script src="/phpwmscm/PUBLIC/js/mindmup-editabletable.js"></script> 
<script src="/phpwmscm/PUBLIC/js/numeric-input-example.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.mousewheel.js"></script>
<!--end-Footer-part-->

<script type="text/javascript">
var act;
//ajax 测试
$.post("/phpwmscm/admin.php/Admin/Ddgz/ceshi/",
		    {
		    
		    },
		    function(data,status){	
		    	switch (data) 
		    	{		    	
		        case "1":
		    	{
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsdl/index');?>'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Ls/index');?>'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsrb/index');?>'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>");   	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Dddy/index');?>'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Rkcl/index');?>'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='<?php echo U('Ddgz/index');?>'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        	break;
		    	}
		    	
		        case "2":
		    	{
		        	$('#sidebar').children("ul").append("<li><a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsdl/index');?>'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Ls/index');?>'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsrb/index');?>'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>"); 
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>"); 
		        break;
		    	}
		    	
		        case "3":
		    	{ 
		        	$('#sidebar').children("ul").append("<li><a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Dddy/index');?>'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Rkcl/index');?>'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='<?php echo U('Ddgz/index');?>'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        break;
		    	}
		    	
		        case "4":
		        {    	    	
		        	
		        break;
		        } 
		        
		        default: 
		        {
		    	break;
		        }
		        
		    	} 
		    	//$("#sidebar").find("li")[0].remove();    
		    });
        $('#fbt3').hide();
		$('#fbt1').hide();
		$('#fbt7').hide();
		$('#fbt15').hide();
		$('#fbt16').hide();
		$('#fbt19').hide();
		$('#fbt20').hide();
		$('#fbt21').hide();
/////////////////////////////////////////////////////////////////////////////////////////////////
//删除当前复选框标记的行。
/* $('#tablea').find("input:checkbox:checked").each(function(){
   		
     	   var temp=$(this).val();
     	  
   		   alert($(this).parent().parent().html());
   		   $(this).parent().parent().remove();
   		  
}); */
//按单品加批次计算 库存数目
var jj1;
$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxdppccx/", {
				
			}, function(data, status) {
				jj1=$.parseJSON(data);	
				//console.log(jj1);
	}); 
/////////////////////////////////////////////////////////////////////////////////////////////////		    
//取得日期
function getDate(d1) {

	/* var	d2=Number(d1);//转换为数值。
	var time = new Date();
	var day = ("0" + (time.getDate()+d2)).slice(-2);
	
	var month = ("0" + (time.getMonth() + 1)).slice(-2);
	var today = time.getFullYear() + "-" + (month) + "-" + (day);
	
	return today; */
	var d2 = Number(d1);//转换为数值。
	var time = new Date();
	var n = time.getTime();
	//有多少天的间隔就加上相对应的秒数。
	//console.log(n); 
	n = n + d2 * 24 * 60 * 60 * 1000;
	//console.log(n); 

	var dd = new Date(+n+8*3600*1000);
	var today = dd.toISOString();
	return today.slice(0, 10);
	//console.log(n1.slice(0,10)); 
}
$('#dbb1').val(getDate(0));
$('#dbb2').val(getDate(0));
/////////////////////////////////////////////////////////////////////////////////////////////////
//动态设置下拉列表
$.post("/phpwmscm/admin.php/Admin/Ddgz/tjajaxsicp/",
		 {
		 		    
		 },
		 function(data,status){	
			
			    var temparr1=data;//取回	    	
		    	varDb_arr1 = temparr1.split(',');//转换为数组
		    	
		    	//console.log(varDb_arr1);
		    			 		
		 		for (var ig = 0; ig < varDb_arr1.length; ig=ig+1) 
		 		{  		
		 			
		 			$('#listItem').append('<option value="' + varDb_arr1[ig] + '">'+ varDb_arr1[ig] +'</option>');
		 		} 
		 		
		});
$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxqrdd/",
		 {
		 		    
		 },
		 function(data,status){	
			
			    var temparr1=data;//取回	    	
		    	varDb_arr1 = temparr1.split(',');//转换为数组
		    	
		    	//console.log(varDb_arr1);
		    			 		
		 		for (var ig = 0; ig < varDb_arr1.length; ig=ig+1) 
		 		{  		
		 			
		 			$('#listItem1').append('<option value="' + varDb_arr1[ig] + '">'+ varDb_arr1[ig] +'</option>');
		 		} 
		 		
		});
		

//$('#tablea').editableTableWidget();
//打印
$('#fbt1').click(function(){	 
	//提交打印就会认为已经打印，会写入数据库，不在打印页面处理了。 
	//把需要选中的订单发送给打印页面。
	var r=confirm("是否整单过账!");
	    if (r==true)
	    {     
	    	 //如果表体中有单品行为空值，则不作任何执行动作。
	          var	kgbj=0;
	    	  $('#wwf').find('tbody').find("tr").each(function(){	
	    		  //在当前行不是第一也不是最后一行的情况下，input等于a99999 且eq5等于空，则认为表体中有新增行没有赋值，做出提示并退出，不执行订单过账。
	    		  if($(this).find("th").eq(2).text()!="序号"&&$(this).find("th").eq(2).text()!=""){ 	    			  
	    			  if($(this).find("input").eq(0).val()=="a99999"&&$(this).find("td").eq(0).text()==""){
	    				  kgbj=1; 
	    				  //console.log($(this).find("input").eq(0).val());
	    				  //console.log($(this).find("td").eq(0).text());
	    			  }	    			 	    			 
	    		  }    				    				    		  
	    	 });
	    	  //只有品名单元格 不为空 才能执行 过账。
	    	 if(kgbj==0) {
	    	 var  temp2Arr="";//缓存check 
	    	 //选择table下所有页脚中的   checkbox:checked    	  
	    	 $('#wwf').find('tfoot').find("input:checkbox:checked").each(function(){
	    			
	    	  	   var temp=$(this).val();
	    	  	   temp2Arr=temp2Arr+temp+",";//生成1,2,3这样的id字符串	    			    
	    			   
	    	  	   });
	    	  var temp2=temp2Arr.slice(0,temp2Arr.length-1);	    	  
	    	  
	    	  //console.log(temp2);
	    	  var temp3="";//保存th
	    	  var temp4="";//保存input
	    	  var temp5="";//保存select
	    	  var temp6="";//保存td
	    	  
	    	  var a9temp3="";//保存th 新增
	    	  var a9temp4="";//保存input 新增
	    	  var a9temp5="";//保存select 新增
	    	  var a9temp6="";//保存td 新增
	    	  //找到当前表的表体中的tr，再定位th 用来判定数据提取。
	    	  $('#wwf').find('tbody').find("tr").each(function(){
	    		  //当前行号2不是 序号 也不是 空值 执行下一步。	
	    		  if($(this).find("th").eq(2).text()!="序号"&&$(this).find("th").eq(2).text()!=""){ 
	    			  
	    			  if($(this).find("input").eq(0).val()!="a99999"){
	    				  $(this).find("th").each(function(){
	    					   var temp=$(this).text();
	    					   temp3=temp3+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });  
	    				  $(this).find("input").each(function(){
	    					   var temp=$(this).val();
	    					   temp4=temp4+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  }); 
	    				  $(this).find("select").each(function(){
	    					   var temp=$(this).val();
	    					   temp5=temp5+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });
	    				  $(this).find("td").each(function(){
	    					   var temp=$(this).text();
	    					   temp6=temp6+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });
	    			  }else{
	    				  $(this).find("th").each(function(){
	    					   var temp=$(this).text();
	    					   a9temp3=a9temp3+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });  
	    				  $(this).find("input").each(function(){
	    					   var temp=$(this).val();
	    					   a9temp4=a9temp4+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  }); 
	    				  $(this).find("select").each(function(){
	    					   var temp=$(this).val();
	    					   a9temp5=a9temp5+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });
	    				  $(this).find("td").each(function(){
	    					   var temp=$(this).text();
	    					   a9temp6=a9temp6+temp+",";//生成1,2,3这样的id字符串	   
	    					  
	    				  });
	    				  
	    			  }
	    			 
	    			 
	    		  }    				    				    		  
	    	 });
	    	   temp3=temp3.slice(0,temp3.length-1);
	    	   temp4=temp4.slice(0,temp4.length-1);
	    	   temp5=temp5.slice(0,temp5.length-1);
	    	   temp6=temp6.slice(0,temp6.length-1);
	    	   a9temp3=a9temp3.slice(0,a9temp3.length-1);
	    	   a9temp4=a9temp4.slice(0,a9temp4.length-1);
	    	   a9temp5=a9temp5.slice(0,a9temp5.length-1);
	    	   a9temp6=a9temp6.slice(0,a9temp6.length-1);
	    	  // console.log(temp4);
	                          
								$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxgc/", {
									arr2 : temp2,
									arr3 : temp3,
									arr4 : temp4,
									arr5 : temp5,
									arr6 : temp6,
									user : $('#userbeifn').text(),
									a9arr3 : a9temp3,
									a9arr4 : a9temp4,
									a9arr5 : a9temp5,
									a9arr6 : a9temp6,
								}, function(data, status) {
									console.log(data);
									
									$('#wwf').find('tfoot').find("input:checkbox:checked").each(function(){
								    			
								    	  	var checkpar=$(this).parent().parent().parent().parent().parent();
								    	  	checkpar.next().remove();
								    	  	checkpar.remove();
								    			   
								    	  	});
									alert("已过账!");
								});
							
							

							} else {
								alert("品名单元格有空值");
							}
	    	         $.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxdppccx/", {
					
				         }, function(data, status) {
					     jj1=$.parseJSON(data);	
					    //console.log(jj1);
		              }); 
	    	   
						} else {
							alert("未过账!");
						}
					});
$('#fbt7').click(function(){	 
	var r=confirm("是否整单作废!");
	    if (r==true)
	    {     
	    	 var temp2Arr="";
	    	 $('#wwf').find('tfoot').find("input:checkbox:checked").each(function(){
	    			
	    	  	   var temp=$(this).val();
	    	  	   temp2Arr=temp2Arr+temp+",";//生成1,2,3这样的id字符串	    			    
	    			   
	    	  });
	    	var temp3=temp2Arr.slice(0,temp2Arr.length-1);
	    	
	    	
	    	$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxzdsc/", {				
				arr3 : temp3,				
				user : $('#userbeifn').text()				
			}, function(data, status) {
				$('#wwf').find('tfoot').find("input:checkbox:checked").each(function(){
	    			
		    	  	var checkpar=$(this).parent().parent().parent().parent().parent();
		    	  	checkpar.next().remove();
		    	  	checkpar.remove();
		    			   
		    	  	});
			    alert("已作废!");
				console.log(data);
			});
			} else {
				alert("未作废!");
			}
});	
$('#fbt15').click(function(){	 
	var r=confirm("是否单品行作废!");
	    if (r==true)
	    {     
	    	var temp2Arr="";
	    	$('#wwf').find('tbody').find("input:checkbox:checked").each(function() {
	    	        if($(this).val()!="a99999"){ 
	    	        	
	    	        	var temp=$(this).val();
	    	        	temp2Arr=temp2Arr+temp+",";//生成1,2,3这样的id字符串	   
	    	        	$(this).parent().parent().parent().remove();
	    	            }
					});	
	    	var temp3=temp2Arr.slice(0,temp2Arr.length-1);
	    	
	    	$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxdpzf/", {				
				arr3 : temp3,				
				user : $('#userbeifn').text()				
			}, function(data, status) {
				//console.log(data);
			});
	    	
			} else {
				alert("未执行!");
			}
});	
	//全选
	$('#fbt3').click(function() {
		var r = confirm("是否全选!");
		if (r == true) {

			var temp = $(".tableinputXz").prop("checked", true);

			alert("已全选!");
		} else {

			var temp = $(".tableinputXz").prop("checked", false);

			alert("未全选!");
		}

	});
	//查询非作废订单
	$('#fbt8')
			.click(
					function() {
						/*  <button id="fbt3">全选</button><button id="fbt1">过账</button> 							          
						<button id="fbt7">整单作废</button><button id="fbt15">单品作废</button> 
						<button id="fbt16">作废订单恢复</button><button id="fbt19">删除作废订单恢复</button>*/
						$('#fbt3').show();
						$('#fbt1').show();
						$('#fbt7').show();
						$('#fbt15').show();
						$('#fbt16').hide();
						$('#fbt19').hide();
						$('#fbt20').show();
						$('#fbt21').show();
						//查询前 清空所有元素。
						$('#wwf').empty()
						$
								.post(
										"/phpwmscm/admin.php/Admin/Ddgz/tjajaxceshi/",
										{
											arr1 : $('#dbb1').val(),
											arr2 : $('#dbb2').val(),
											arr3 : $('#fbt10').val(),
											arr4 : $('#fbt11').val(),
											arr5 : $('#fbt12').val(),
											arr6 : $('#fbt14').val(),
										},
										function(data, status) {
											var temparr1 = data.slice(0, data
													.search("fenge"));
											var temparr2 = data.slice(data
													.search("fenge") + 5,
													data.length);

											var j1 = $.parseJSON(temparr1);
											var j2 = $.parseJSON(temparr2);
											//保存变量

											var tanblestart = "<table  class='table table-bordered table-striped'>";
											var tanbleend = "</table>";

											var btbtid1 = "btbtone";
											var btbtid2 = "btbttow";
											var btbtid3 = "kgbj";
											var table = "tb";

											for (var i = 0; i < j1.length; i++) {
												var aa1 = btbtid1 + i;
												var bb1 = btbtid2 + i;
												var cc1 = btbtid3 + i;
												var ee1 = table + i;
                                                 
												
												//表头
												var biaogearr = "";
												biaogearr = biaogearr
														+ tanblestart;

												biaogearr = biaogearr
														+ "<tfoot><tr><th><nobr><input type=checkbox style='position: relative; left: 0px; top: -55px; right:0px ' class='tableinputXz' value="+j1[i].etddbm+"></nobr></th></tr></tfoot>"
														+ "<thead id="+aa1+">"
														+ "<tr>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr>订单状态:已打印|-|</nobr></th>"
														+ "<th><nobr>订单编码:"
														+ j1[i].etddbm
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>订单日期:"
														+ j1[i].ddriqi
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>送货日期:"
														+ j1[i].pcriq
														+ "|-|</nobr></th>"
														+ "<th><nobr>客户:"
														+ j1[i].khmc
														+ "|-|</nobr></th>"
														+ "<th><nobr>门店:"
														+ j1[i].khmd
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>收货人:"
														+ j1[i].shr
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>收货人电话:"
														+ j1[i].shrdh
														+ "|-|</nobr></th>"
														/*  + "<th style='color:#f0f'><nobr>三方订单号:"+j1[i].sfddh+"|-|</nobr></th>" */
														+ "<th><nobr>地址:"
														+ j1[i].mddz
														+ "|-|</nobr></th>"
														+ "</tr>"
														+ "<tr>"
														+ "<th><nobr></nobr></th>"

														+ "<th style='color:#f0f'><nobr>订单备注:"
														+ j1[i].ddbeizhu
														+ "|-|</nobr></th>"
														/*  + "<th style='color:#f0f'><nobr>配送类型:"+j1[i].pslx+"|-|</nobr></th>"	 */
														+ "<th style='color:#f0f'><nobr>订单推送人:"
														+ j1[i].ddscz
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>订单推送时间:"
														+ j1[i].scrqsj
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>打印次数:"
														+ j1[i].dybj
														+ "|-|</nobr></th>"
														+ "<th style='color:#f0f'><nobr>是否过账:"
														+ j1[i].gzbj
														+ "|-|</nobr></th>"
														+ "</tr>"
														+ "</thead>"
														+ "</table>"
														+ "<table id="+ee1+" class='table table-bordered table-striped'>"
														+ "<tbody id="+bb1+">"
														+ "<tr>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr>序号</nobr></th>"
														+ "<th style='color:#f0f'><nobr>出库日期</nobr></th>"
														+ "<th><nobr>商品编码</nobr></th>"
														+ "<th style='color:#f0f'><nobr>品名</nobr></th>"
														+ "<th><nobr>商品条码</nobr></th>"
														+ "<th><nobr>单品规格</nobr></th>"
														+ "<th><nobr>箱规</nobr></th>"
														+ "<th><nobr>货物类型</nobr></th>"
														+ "<th style='color:#f0f'><nobr>配送类型</nobr></th>"
														+ "<th style='color:#f0f'><nobr>件数</nobr></th>"
														+ "<th style='color:#f0f'><nobr>出库重量</nobr></th>"
														+ "<th style='color:#f0f'><nobr>单品批次</nobr></th>"
														+ "<th style='color:#f0f'><nobr>出库备注</nobr></th>"
														+ "<th style='color:#f0f'><nobr>订单号</nobr></th>"
														+ "<th style='color:#f0f'><nobr>库存说明</nobr></th>"
														+ "</tr>";
												var tempjssjs = 0;
												var ysslzj = 0;
												var xhcx = 0;
												for (var a = 0; a < j2.length; a++) {
													if (j1[i].etddbm == j2[a].etddbm) {
														//计算现有库存。
														var xykcsl=0;
														for (var aaa = 0; aaa < jj1.length; aaa++) {
															if(j2[a].pinming==jj1[aaa].pinming&&j2[a].ckpc==jj1[aaa].pici){
																xykcsl=jj1[aaa].zskc
															}
														}
														//合计送货数量	 
														tempjssjs = tempjssjs
																+ Number(j2[a].shjs);
														//计算并合计验收总数
														var tempjsyssl = Number(j2[a].ckdpzl);
														ysslzj = ysslzj+ tempjsyssl;
														//序号重新计算
														xhcx = xhcx + 1;
														
														
														biaogearr = biaogearr
																+ "<tr>"
																+ "<th><nobr>"+j2[a].beiyong1+"</nobr></th>"
																+ "<th><nobr><input type=checkbox  class='tableinputtbody' value="+j2[a].id+"></nobr></th>"
																+ "<th><nobr>"
																+ xhcx
																+ "</nobr></th>"
																+ "<th style='color:#f0f'><nobr><input type=date  value="
																+ j1[i].ckrq
																+ "></nobr></th>"
																+ "<th><nobr>"
																+ j2[a].spbm
																+ "</nobr></th>"
																+ "<th><nobr>"
																+ j2[a].pinming
																+ "</nobr></th>"
																+ "<th><nobr>"
																+ j2[a].sptm
																+ "</nobr></th>"
																+ "<th><nobr>"
																+ j2[a].dpgg
																+ "</nobr></th>"
																+ "<th><nobr>"
																+ j2[a].xianggui
																+ "</nobr></th>"
																+ "<th><nobr>"
																+ j2[a].hwlx
																+ "</nobr></th>"
																+ "<th><select>"
																+ "<option value ="+j1[i].pslx+">"
																+ j1[i].pslx
																+ "</option>"
																+ "<option value ="+j1[i].pslx1+">"
																+ j1[i].pslx1
																+ "</option>"
																+ "<option value ="+j1[i].pslx2+">"
																+ j1[i].pslx2
																+ "</option>"
																+ "</select></th>"
																+ "<td style='color:#f0f'><nobr>"
																+ j2[a].shjs
																+ "</nobr></td>"
																+ "<td style='color:#f0f'><nobr>"
																+ tempjsyssl
																+ "</nobr></td>"
																+ "<th style='color:#f0f'><nobr><input type=date class=rkpcbj value="+j2[a].ckpc+"></nobr></th>"
																+ "<td style='color:#f0f'><nobr>"+j2[a].ckbz+"</nobr></td>"
																+ "<th style='color:#f0f'><nobr>"
																+ j2[a].etddbm
																+ "</nobr></th>"
																+ "<th style='color:#f0f'><nobr>"+xykcsl+"</nobr></th>"
																+ "</tr>";
													}
												}
												biaogearr = biaogearr
														+ "<tr>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "<th><nobr>"
														+ tempjssjs
														+ "</nobr></th>"
														+ "<th><nobr>"
														+ ysslzj
														+ "</nobr></th>"
														+ "<th><nobr></nobr></th>"
														+ "</tr>";
												biaogearr = biaogearr
														+ "</tbody>"
														+ tanbleend;
												$('#wwf').append(biaogearr);
												//////////////////////////////////////////////////////////////////////////////////////	
												var iDatejsdt = "<script type='text/javascript'>";

												iDatejsdt = iDatejsdt
														+ "$('#"
														+ ee1
														+ "').editableTableWidget();"
														
														+ "$('#"
														+ bb1
														+ "').hide();"
														+ "var "
														+ cc1
														+ "=0;"
														+ "$('#"
														+ aa1
														+ "').click(function(){"
														+ "switch (" + cc1
														+ ")" + "{" + "case 0:"
														+ "{" + "$('#" + bb1
														+ "').hide(100);" + " "
														+ cc1 + "=1;"
														+ "break;" + "}"
														+ "case 1:" + "{"
														+ "$('#" + bb1
														+ "').show(100);" + " "
														+ cc1 + "=0;"
														+ "break;" + "}"
														+ "default:" + "{"
														+ "break;" + "}" + "}"
														+ "});"

											
												$('#wwf').append(iDatejsdt);

											}
											 var iDatejsdt = "<script type='text/javascript'>";				
												iDatejsdt = iDatejsdt
												        + "$('.rkpcbj').blur(function(e) {"		
												          //真实库存判定
												        //+ "console.log($(this).val());"
										    			+ "var datetemp='';"
										    			+ "if($(this).val()==''){"
										    			+ "datetemp='0000-00-00'"		    	        	  
										    			+ "}else{"
										    			+ "datetemp=$(this).val();	"	    	        	  
										    			+ "}"
										    			//更新数据时找到对应库存。
										    			+ "var fystemp=$(this).parent().parent().parent().find('th').eq(5).text();"
										    			//+ "var fystemp=$(this).parent().parent().parent().html();" 
										    			+ "console.log(fystemp);"
										    			+ "for (var it = 0; it < jj1.length; it=it+1)" 
										    			+ "{" 		    			
										    			+ "if(fystemp==jj1[it]['pinming']&&datetemp==jj1[it]['pici']){"		    						  
										    			+ "$(this).parent().parent().parent().find('th').eq(13).text(jj1[it]['zskc']);"
										    			+ "break;"
										    			+ "}"
										    			+ "$(this).parent().parent().parent().find('th').eq(13).text('仓库无货，请注意');"		    				    					
										    			+ "}"				        
												        + "e.preventDefault();"
												        + "e.stopPropagation();"					       
												        + "});" 
														"<\/script>";
												$('#wwf').append(iDatejsdt);
										});

						//加载完成后添加input离去事件。$('textarea').unbind('blur').bind('blur', function()
						//$('#test').blur(function(e) {
					/*  $('input').blur(function(e) {
						   alert("文本已被修改");				
					  }); */
						$('#test').blur(function(e) {
											/* $(".tableinputtbody").each(function(){	
												  console.log($(this).val());
													if($(this).prop("checked")){
														 alert($(this).val());
													}$('table').find("input:checkbox:checked").each(function(){
												
											 }); */
											/*  $('#wwf').find('tbody').find("input:checkbox:checked").each(function(){	
												
															 alert($(this).val());
														
													
												 }); */
											switch (act.index()) {
											case 11: {

												//重新计算 单品验收数量
												var temparr = Number(act.text());
												if (!isNaN(temparr)) {
												
												} else {

													act.text(0)
													act.next().text(0);
													alert("不是数字!");
												}
												//重新计算订单总件数和总验收数量
												var dpzs = 0;
												var dpyszs = 0;
												act.parent().parent().find("td").each(function() {
																	if ($(this).index() == 11) {
																		dpzs = dpzs+ Number($(this).text());
																		dpyszs = dpyszs+ Number($(this).next().text())
																				
																	}
																});
												//找到总件数和验收数量的位置，并更新。
												act.parent().parent()
														.find("tr").last()
														.find("th").eq(11)
														.text(dpzs);
												act.parent().parent()
														.find("tr").last()
														.find("th").eq(12)
														.text(dpyszs); 
												break;
											}
											case 12: {

												//重新计算 单品验收数量
												var temparr = Number(act.text());
												if (!isNaN(temparr)) {
												
												} else {

													act.text(0)												
													alert("不是数字!");
												}
												//重新计算订单总件数和总验收数量
												var dpzs = 0;
												var dpyszs = 0;
												act.parent().parent().find("td").each(function() {
																	if ($(this).index() == 12) {
																		dpzs = dpzs+ Number($(this).prev().text());
																		dpyszs = dpyszs+ Number($(this).text())
																				
																	}
																});
												//找到总件数和验收数量的位置，并更新。
												act.parent().parent()
														.find("tr").last()
														.find("th").eq(11)
														.text(dpzs);
												act.parent().parent()
														.find("tr").last()
														.find("th").eq(12)
														.text(dpyszs); 
												break;
											}
											case 5: {
												//以index标记对当前单元格的同辈进行赋值。
												 for (var ig = 0; ig < inputlist.length; ig = ig + 10) {
													//清空开关
													var qkkg = 0;
													if (act.text() == inputlist[ig + 2]) {
														act
																.prev()
																.text(
																		inputlist[ig + 1]);
														act
																.next()
																.text(
																		inputlist[ig + 3]);
														act
																.next()
																.next()
																.text(
																		inputlist[ig + 4]);
														act
																.next()
																.next()
																.next()
																.text(
																		inputlist[ig + 5]);
														act
																.next()
																.next()
																.next()
																.next()
																.text(
																		inputlist[ig + 8]);
														//act.next().next().next().next().next().text(inputlist[ig+9]);

													

														//重新计算订单总件数和总验收数量
														var dpzs = 0;
														var dpyszs = 0;
														act.parent().parent().find("td").each(function() {
																			if ($(this).index() == 11) {
																				dpzs = dpzs+ Number($(this).text());
																				dpyszs = dpyszs+ Number($(this).next().text());
																			}
																		});
														//找到总件数和验收数量的位置，并更新。
														act.parent().parent()
																.find("tr")
																.last().find(
																		"th")
																.eq(11).text(
																		dpzs);
														act.parent().parent()
																.find("tr")
																.last().find(
																		"th")
																.eq(12).text(
																		dpyszs);
														//真实库存判定
										    			  var datetemp="";
										    	          if(act.parent().find("input").eq(2).val()==""){
										    	        	  datetemp="0000-00-00"		    	        	  
										    	          }else{
										    	        	  datetemp=act.parent().find("input").eq(2).val();		    	        	  
										    	          }
										    	          //console.log(act.parent().find("input").eq(2).val());
										    	          
										    			  //更新数据时找到对应库存。
										    				for (var it = 0; it < jj1.length; it=it+1) 
												    		{ 
										    					
										    					if(act.text()==jj1[it]["pinming"]&&datetemp==jj1[it]["pici"]){		    						  
										    						act.parent().find("th").eq(12).text(jj1[it]["zskc"]);
										    						//找到数据就退出当前 for循环。
										    						break;
										    					}	
										    					act.parent().find("th").eq(12).text(('仓库无货，新品入库'));	
												    		}

														break;
													} else {

														//没有找到变为1 
														qkkg = 1;

													}
												}
												//清空
												if (qkkg == 1) {
													act.text("");
													act.prev().text("");
													act.next().text("");
													act.next().next().text("");
													act.next().next().next()
															.text("");
													act.next().next().next()
															.next().text("");
													act.next().next().next()
															.next().next()
															.next().text(0);
													act.next().next().next()
															.next().next()
															.next().next()
															.text(0);

													//alert("单品不在库存或单元格为空，请添加！");
													//阻止默认行为，停止冒泡
													e.stopPropagation()
													return false;
												} 

												break;
											}
											default: {
												break;
											}
											}
										});

					});
	//拿到id
	//var actid=$(this).parent().parent().parent().parent().parent().next().attr('id');
	//给新增行标记 序号

	//新增空行	
	$('#fbt20')
			.click(
					function() {
						var xzhjs = 0;
						$('#wwf')
								.find('tfoot')
								.find("input:checkbox:checked")
								.each(
										function() {
											//找到当前表头行的复选框 用它来定位下一个需要 新增行的表	   alert($(this).attr('id'))
											var acttable = $(this).parent()
													.parent().parent().parent()
													.parent().next();
											//序号计算
											xzhjs = Number(acttable.find('tr')
													.last().prev().find('th')
													.eq(2).text()) + 1;
											//找到配送类型
											var baocunleix = acttable
													.find('tr').last().prev()
													.find('select').eq(0).val();
											//找到当前订单编码
											var zdddbm = acttable.find('tr')
													.first().next().find('th')
													.eq(12).text();

											var temp = "";
											//选择不同的配送类型排列。
											if (baocunleix == "市内") {
												temp = "<th><select>"
														+ "<option value ='市内'>市内</option>"
														+ "<option value ='零担'>零担</option>"
														+ "<option value ='自提'>自提</option>"
														+ "</select></th>";
											}
											if (baocunleix == "零担") {
												temp = "<th><select>"
														+ "<option value ='零担'>零担</option>"
														+ "<option value ='市内'>市内</option>"
														+ "<option value ='自提'>自提</option>"
														+ "</select></th>";
											}
											if (baocunleix == "自提") {
												temp = "<th><select>"
														+ "<option value ='自提'>自提</option>"
														+ "<option value ='市内'>市内</option>"
														+ "<option value ='零担'>零担</option>"
														+ "</select></th>";
											}

											//新增代码
											var newtable1 = "<tr>"
													+ "<th><nobr>新增</nobr></th>"
													+ "<th><nobr><input type=checkbox  class='tableinputtbody' value='a99999'></nobr></th>"
													+ "<th><nobr>"
													+ xzhjs
													+ "</nobr></th>"
													+ "<th style='color:#f0f'><nobr><input type=date  value="
													+ getDate(0)
													+ "></nobr></th>"
													+ "<th><nobr></nobr></th>"
													+ "<td style='color:#f0f'><nobr></nobr></td>"
													+ "<th><nobr></nobr></th>"
													+ "<th><nobr></nobr></th>"
													+ "<th><nobr></nobr></th>"
													+ "<th><nobr></nobr></th>"
													+ temp
													+ "<td style='color:#f0f'><nobr>0</nobr></td>"
													+ "<td style='color:#f0f'><nobr>0</nobr></td>"
													+ "<th style='color:#f0f'><nobr><input class=rkpcbj1 type=date></nobr></th>"
													+ "<td style='color:#f0f'><nobr></nobr></td>"
													+ "<th style='color:#f0f'><nobr>"
													+ zdddbm + "</nobr></th>"
													+ "<th style='color:#f0f'><nobr></nobr></th>"
													+ "</tr>";

											acttable.find('tr').last().before(newtable1);

											//加载编js代码
											var actid = $(this).parent()
													.parent().parent().parent()
													.parent().next().attr('id');
											        $('#' + actid).unbind();
											        $('#' + actid)
													.editableTableWidget();
											        $('#' + actid).on(
													'click keypress dblclick',
													showEditordp);
											

										});
						var iDatejsdt = "<script type='text/javascript'>";				
						iDatejsdt = iDatejsdt
						        + "$('.rkpcbj1').blur(function(e) {"		
						          //真实库存判定
						        //+ "console.log($(this).val());"
				    			+ "var datetemp='';"
				    			+ "if($(this).val()==''){"
				    			+ "datetemp='0000-00-00'"		    	        	  
				    			+ "}else{"
				    			+ "datetemp=$(this).val();	"	    	        	  
				    			+ "}"
				    			//更新数据时找到对应库存。
				    			+ "var fystemp=$(this).parent().parent().parent().find('td').eq(0).text();"
				    			//+ "var fystemp=$(this).parent().parent().parent().html();" 
				    			+ "console.log(fystemp);"
				    			+ "for (var it = 0; it < jj1.length; it=it+1)" 
				    			+ "{" 		    			
				    			+ "if(fystemp==jj1[it]['pinming']&&datetemp==jj1[it]['pici']){"		    						  
				    			+ "$(this).parent().parent().parent().find('th').eq(12).text(jj1[it]['zskc']);"
				    			+ "break;"
				    			+ "}"
				    			+ "$(this).parent().parent().parent().find('th').eq(12).text('仓库无货，请注意');"		    				    					
				    			+ "}"				        
						        + "e.preventDefault();"
						        + "e.stopPropagation();"					       
						        + "});" 
								"<\/script>";
						$('#wwf').append(iDatejsdt);
					});
						//删除新增空行	 
						$('#fbt21')
								.click(
										function() {
											//删除新增行需要重新计算 序号 总件数 验收总件数。	 
											$('#wwf')
													.find('tbody')
													.find(
															"input:checkbox:checked")
													.each(
															function() {
																if ($(this)
																		.val() == 'a99999') {
																	//缓存变量
																	var checkfys = $(
																			this)
																			.parent()
																			.parent()
																			.parent()
																			.parent()
																			.parent();
																	//删除复选框所在的行
																	$(this)
																			.parent()
																			.parent()
																			.parent()
																			.remove();
																	//删除新增行时，重绘tboy的序号
																	var xuhaoscch = 1;
																	checkfys
																			.children(
																					"tbody")
																			.children(
																					"tr")
																			.children(
																					"th")
																			.each(
																					function() {

																						//console.log($(this).index());
																						//console.log($(this).text());
																						if ($(
																								this)
																								.index() == 2
																								&& $(
																										this)
																										.text() != "序号"
																								&& $(
																										this)
																										.text() != "") {
																							$(
																									this)
																									.text(
																											xuhaoscch);
																							xuhaoscch = xuhaoscch + 1;
																						}

																					});
																	//删除后给新增计数赋值。
																	//xzhjs=xuhaoscch;

																	//删除新增行时，重绘总件数和总验收数				
																	var dpzs = 0;
																	var dpyszs = 0;
																	checkfys
																			.children(
																					"tbody")
																			.children(
																					"tr")
																			.children(
																					"td")
																			.each(
																					function() {

																						//console.log($(this).index());
																						//console.log($(this).text());
																						if ($(
																								this)
																								.index() == 11) {

																							dpzs = dpzs
																									+ Number($(
																											this)
																											.text())
																							dpyszs = dpyszs
																									+ Number($(
																											this)
																											.text())
																									* Number($(
																											this)
																											.prev()
																											.prev()
																											.prev()
																											.text())
																							//console.log(dpzs);
																							//console.log(dpyszs);
																						}

																					});

																	checkfys
																			.find(
																					"tr")
																			.last()
																			.find(
																					"th")
																			.eq(
																					11)
																			.text(
																					dpzs);
																	checkfys
																			.find(
																					"tr")
																			.last()
																			.find(
																					"th")
																			.eq(
																					12)
																			.text(
																					dpyszs);

																} else {

																}

															});
										});

					

	$('#fbt17').click(function() {
		/*  <button id="fbt3">全选</button><button id="fbt1">过账</button> 							          
		<button id="fbt7">整单作废</button><button id="fbt15">单品作废</button> 
		<button id="fbt16">作废订单恢复</button><button id="fbt19">删除作废订单恢复</button>*/
		$('#fbt3').hide();
		$('#fbt1').hide();
		$('#fbt20').hide();
		$('#fbt21').hide();
		$('#fbt7').hide();
		$('#fbt15').hide();
		$('#fbt16').show();
		$('#fbt19').show();
		$('#wwf').empty()
		$.post(
						"/phpwmscm/admin.php/Admin/Ddgz/tjajaxceshi111/",
						{
							arr1 : $('#dbb1').val(),
							arr2 : $('#dbb2').val(),
							arr3 : $('#fbt10').val(),
							arr4 : $('#fbt11').val(),
							arr5 : $('#fbt12').val(),
							arr6 : $('#fbt14').val(),
						},
						function(data, status) {
							var temparr1 = data.slice(0, data
									.search("fenge"));
							var temparr2 = data.slice(data
									.search("fenge") + 5,
									data.length);

							var j1 = $.parseJSON(temparr1);
							var j2 = $.parseJSON(temparr2);
							//保存变量

							var tanblestart = "<table  class='table table-bordered table-striped'>";
							var tanbleend = "</table>";

							var btbtid1 = "btbtone";
							var btbtid2 = "btbttow";
							var btbtid3 = "kgbj";
							var table = "tb";

							for (var i = 0; i < j1.length; i++) {
								var aa1 = btbtid1 + i;
								var bb1 = btbtid2 + i;
								var cc1 = btbtid3 + i;
								var ee1 = table + i;

								//表头
								var biaogearr = "";
								biaogearr = biaogearr
										+ tanblestart;

								biaogearr = biaogearr
										+ "<tfoot><tr><th><nobr></nobr></th></tr></tfoot>"
										+ "<thead id="+aa1+">"
										+ "<tr>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr>订单状态:已打印|-|</nobr></th>"
										+ "<th><nobr>订单编码:"
										+ j1[i].etddbm
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>订单日期:"
										+ j1[i].ddriqi
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>送货日期:"
										+ j1[i].pcriq
										+ "|-|</nobr></th>"
										+ "<th><nobr>客户:"
										+ j1[i].khmc
										+ "|-|</nobr></th>"
										+ "<th><nobr>门店:"
										+ j1[i].khmd
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>收货人:"
										+ j1[i].shr
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>收货人电话:"
										+ j1[i].shrdh
										+ "|-|</nobr></th>"
										/*  + "<th style='color:#f0f'><nobr>三方订单号:"+j1[i].sfddh+"|-|</nobr></th>" */
										+ "<th><nobr>地址:"
										+ j1[i].mddz
										+ "|-|</nobr></th>"
										+ "</tr>"
										+ "<tr>"
										+ "<th><nobr></nobr></th>"

										+ "<th style='color:#f0f'><nobr>订单备注:"
										+ j1[i].ddbeizhu
										+ "|-|</nobr></th>"
										/*  + "<th style='color:#f0f'><nobr>配送类型:"+j1[i].pslx+"|-|</nobr></th>"	 */
										+ "<th style='color:#f0f'><nobr>订单推送人:"
										+ j1[i].ddscz
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>订单推送时间:"
										+ j1[i].scrqsj
										+ "|-|</nobr></th>"
										+ "<th style='color:#f0f'><nobr>打印次数:"
										+ j1[i].dybj
										+ "|-|</nobr></th>"
										+ "</tr>"
										+ "</thead>"
										+ "</table>"
										+ "<table id="+ee1+" class='table table-bordered table-striped'>"
										+ "<tbody id="+bb1+">"
										+ "<tr>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr>序号</nobr></th>"
										+ "<th style='color:#f0f'><nobr>出库日期</nobr></th>"
										+ "<th><nobr>商品编码</nobr></th>"
										+ "<th style='color:#f0f'><nobr>品名</nobr></th>"
										+ "<th><nobr>商品条码</nobr></th>"
										+ "<th><nobr>单品规格</nobr></th>"
										+ "<th><nobr>箱规</nobr></th>"
										+ "<th><nobr>货物类型</nobr></th>"
										+ "<th style='color:#f0f'><nobr>配送类型</nobr></th>"
										+ "<th style='color:#f0f'><nobr>件数</nobr></th>"
										+ "<th style='color:#f0f'><nobr>出库重量</nobr></th>"
										+ "<th style='color:#f0f'><nobr>单品批次</nobr></th>"
										+ "<th style='color:#f0f'><nobr>出库备注</nobr></th>"
										+ "<th style='color:#f0f'><nobr>订单号</nobr></th>"

										+ "</tr>";
								var tempjssjs = 0;
								var ysslzj = 0;
								var xhcx = 0;
								for (var a = 0; a < j2.length; a++) {
									if (j1[i].etddbm == j2[a].etddbm) {
										//合计送货数量	 
										tempjssjs = tempjssjs
												+ Number(j2[a].shjs);
										//计算并合计验收总数
										var tempjsyssl =Number(j2[a].ckdpzl);
										ysslzj = ysslzj + tempjsyssl;
										//序号重新计算
										xhcx = xhcx + 1
										biaogearr = biaogearr
												+ "<tr>"
												+ "<th><nobr>"+j2[a].beiyong1+"</nobr></th>"
												+ "<th><nobr><input type=checkbox  class='tableinputtbody' value="+j2[a].id+"></nobr></th>"
												+ "<th><nobr>"
												+ xhcx
												+ "</nobr></th>"
												+ "<th style='color:#f0f'><nobr><input type=date  value="
												+ j1[i].ckrq
												+ "></nobr></th>"
												+ "<th><nobr>"
												+ j2[a].spbm
												+ "</nobr></th>"
												+ "<th><nobr>"
												+ j2[a].pinming
												+ "</nobr></th>"
												+ "<th><nobr>"
												+ j2[a].sptm
												+ "</nobr></th>"
												+ "<th><nobr>"
												+ j2[a].dpgg
												+ "</nobr></th>"
												+ "<th><nobr>"
												+ j2[a].xianggui
												+ "</nobr></th>"
												+ "<th><nobr>"
												+ j2[a].hwlx
												+ "</nobr></th>"
												+ "<th><select>"
												+ "<option value ="+j1[i].pslx+">"
												+ j1[i].pslx
												+ "</option>"
												+ "<option value ="+j1[i].pslx1+">"
												+ j1[i].pslx1
												+ "</option>"
												+ "<option value ="+j1[i].pslx2+">"
												+ j1[i].pslx2
												+ "</option>"
												+ "</select></th>"
												+ "<th style='color:#f0f'><nobr>"
												+ j2[a].shjs
												+ "</nobr></th>"
												+ "<th style='color:#f0f'><nobr>"
												+ tempjsyssl
												+ "</nobr></th>"
												+ "<th style='color:#f0f'><nobr><input type=date value="+j2[a].ckpc+"></nobr></th>"
												+ "<th style='color:#f0f'><nobr>"+j2[a].ckbz+"</nobr></th>"
												+ "<th style='color:#f0f'><nobr>"
												+ j2[a].etddbm
												+ "</nobr></th>"
												+ "</tr>";
									}
								}
								biaogearr = biaogearr
										+ "<tr>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "<th><nobr>"
										+ tempjssjs
										+ "</nobr></th>"
										+ "<th><nobr>"
										+ ysslzj
										+ "</nobr></th>"
										+ "<th><nobr></nobr></th>"
										+ "</tr>";
								biaogearr = biaogearr
										+ "</tbody>"
										+ tanbleend;
								$('#wwf').append(biaogearr);
								//////////////////////////////////////////////////////////////////////////////////////	
								var iDatejsdt = "<script type='text/javascript'>";

								iDatejsdt = iDatejsdt
										+ "$('#"
										+ ee1
										+ "').editableTableWidget();"
										+ "$('#"
										+ bb1
										+ "').hide();"
										+ "var "
										+ cc1
										+ "=0;"
										+ "$('#"
										+ aa1
										+ "').click(function(){"
										+ "switch (" + cc1
										+ ")" + "{" + "case 0:"
										+ "{" + "$('#" + bb1
										+ "').hide(100);" + " "
										+ cc1 + "=1;"
										+ "break;" + "}"
										+ "case 1:" + "{"
										+ "$('#" + bb1
										+ "').show(100);" + " "
										+ cc1 + "=0;"
										+ "break;" + "}"
										+ "default:" + "{"
										+ "break;" + "}" + "}"
										+ "});"

								iDatejsdt = iDatejsdt
										+ "<\/script>";
								$('#wwf').append(iDatejsdt);

							}

						});

	});
	//全部订单
	$('#fbt18').click(function() {
	
		$('#fbt20').hide();
		$('#fbt21').hide();
		$('#fbt3').hide();
		$('#fbt1').hide();
		$('#fbt7').hide();
		$('#fbt15').hide();
		$('#fbt16').hide();
		$('#fbt19').hide();
		//查询前 清空所有元素。

		$('#wwf').empty()
		$.post("/phpwmscm/admin.php/Admin/Ddgz/tjajaxceshi222/",
				{
					arr1 : $('#dbb1').val(),
					arr2 : $('#dbb2').val(),
					arr3 : $('#fbt10').val(),
					arr4 : $('#fbt11').val(),				
					arr5 : $('#fbt114').val(),
				},
				function(data, status) {
					var j1 = $.parseJSON(data);				
				    console.log(j1);
				    
				        var tanblestart = "<table  class='table table-bordered table-striped'>";
					    var tanbleend = "</table>";
						//表头
						var biaogearr = "";
						biaogearr = biaogearr
								+ tanblestart;

						biaogearr = biaogearr
								
								+ "<thead>"
								+ "<tr>"
								+ "<th><nobr>订单过账标记</nobr></th>"
								+ "<th><nobr>订单作废标记</nobr></th>"
								+ "<th><nobr>新增标记</nobr></th>"
								+ "<th><nobr>订单编码</nobr></th>"
								+ "<th><nobr>出库日期</nobr></th>"
								+ "<th><nobr>客户名称</nobr></th>"
								+ "<th><nobr>门店</nobr></th>"
								+ "<th><nobr>收货人</nobr></th>"
								+ "<th><nobr>收货人电话</nobr></th>"
								+ "<th><nobr>三方订单号</nobr></th>"
								+ "<th><nobr>门店地址</nobr></th>"
								+ "<th><nobr>订单备注</nobr></th>"
								+ "<th><nobr>订单日期</nobr></th>"
								+ "<th><nobr>送货日期</nobr></th>"
								+ "<th><nobr>配送类型</nobr></th>"
								+ "<th><nobr>商品编码</nobr></th>"
								+ "<th><nobr>商品名称</nobr></th>"
								+ "<th><nobr>商品条码</nobr></th>"
								+ "<th><nobr>商品规格</nobr></th>"
								+ "<th><nobr>商品箱规</nobr></th>"
								+ "<th><nobr>商品货物类型</nobr></th>"
								+ "<th><nobr>商品备注</nobr></th>"
								+ "<th><nobr>件数</nobr></th>"
								+ "<th><nobr>重量</nobr></th>"
								+ "<th><nobr>批次</nobr></th>"
								+ "<th><nobr>出库备注</nobr></th>"
								+ "<th><nobr>订单推送者</nobr></th>"
								+ "<th><nobr>订单推送日期</nobr></th>"
								+ "<th><nobr>订单推送标记</nobr></th>"
								+ "<th><nobr>订单打印者</nobr></th>"
								+ "<th><nobr>订单打印日期</nobr></th>"
								+ "<th><nobr>订单打印次数</nobr></th>"
								+ "<th><nobr>订单过账操作员</nobr></th>"
								+ "<th><nobr>订单过账日期</nobr></th>"
								+ "<th><nobr>订单派车者</nobr></th>"
								+ "<th><nobr>订单派车日期</nobr></th>"
								+ "<th><nobr>订单派车标记</nobr></th>"
								+ "</tr>"
								+ "</thead>"														
								+ "<tbody>";
								for (var a = 0; a < j1.length; a++) {
									biaogearr = biaogearr+ "<tr>"	
								+ "<th><nobr>"+ j1[a].gzbj+ "</nobr></th>"	
								+ "<th><nobr>"+ j1[a].ddzfbj+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].beiyong1+ "</nobr></th>"	
								+ "<th><nobr>"+ j1[a].etddbm+ "</nobr></th>"	
								+ "<th><nobr>"+ j1[a].ckrq+ "</nobr></th>"	
								+ "<th><nobr>"+ j1[a].khmc+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].khmd+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].shr+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].shrdh+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].sfddh+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].mddz+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ddbeizhu+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ddriqi+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pcriq+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pslx+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].spbm+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pinming+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].sptm+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].dpgg+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].xianggui+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].hwlx+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].dpbeizhu+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].shjs+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ckdpzl+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ckpc+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ckbz+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ddscz+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].scrqsj+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].querendd+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].dyczy+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].dyjtsj+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].dybj+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ddckczy+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].ddckrq+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pcczy+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pcdate+ "</nobr></th>"
								+ "<th><nobr>"+ j1[a].pcbj+ "</nobr></th>"
								+ "</tr>";	
								}
								biaogearr = biaogearr+ "</tbody>"
								+ tanbleend;
						$('#wwf').append(biaogearr);
						
						

					
				});
		
	});
	//恢复订单
	$('#fbt16').click(function() {
		
		var r=confirm("是否整单恢复!");
	    if (r==true)
	    {     
	    	var temp2Arr="";
	    	$('#wwf').find('tbody').find("input:checkbox:checked").each(function() {	    	        
	    	        	var temp=$(this).val();
	    	        	temp2Arr=temp2Arr+temp+",";//生成1,2,3这样的id字符串	   
	    	        	$(this).parent().parent().parent().remove();
					});	
	    	var temp3=temp2Arr.slice(0,temp2Arr.length-1);
	    	
	    	$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxzdsc111/", {				
				arr3 : temp3,				
				user : $('#userbeifn').text()				
			}, function(data, status) {
				console.log(data);
			});
	    	
	    	    
			} else {
				alert("未恢复!");
			}
		

	});
	//测试post json数据
$('#fbt9').click(function() {
		
		    	
	    	$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxceshi/", {				
				json : jj1,				
						
			}, function(data, status) {
				console.log(data);
			});	    		    	

});
	//这个变量在js中赋值，保存当前表格td焦点。 
	var inputlist = "";//缓存单品信息。
	//取回单品信息
	$.post("/phpwmscm/admin.php/Admin/Ddgz/ajaxdpbm/", {

	}, function(data, status) {

		inputlist = data.split(',');//转换为数组		
		//console.log(inputlist);
	});
	//生成下拉列表框。
	function showEditordp() {

		$('#typelist').empty();//删除datalist的所有子元素。
		switch (act.index()) {
		case 5: {
			$('#typelist').append('<option value=""></option>');//先加个空白值。
			for (var ig = 0; ig < inputlist.length; ig = ig + 10) {
				$('#typelist').append(
						'<option value="' + inputlist[ig+2] + '"></option>');
			}
			break;
		}

		default: {
			break;
		}
		}

	}
</script>

</body>

</html>